import CryptoJS from 'crypto-js'
// let keyStr = '' //加密秘钥
let ivStr = '' //十六位十六进制数作为密钥偏移量
export default {
	aesEncrypt: function(word, aeskey) {
		let key = CryptoJS.enc.Utf8.parse(aeskey);
		// let key = CryptoJS.enc.Utf8.parse('YEBU6SQH1NX8C2W9');


		// let iv = CryptoJS.enc.Utf8.parse(ivStr);
		let srcs = CryptoJS.enc.Utf8.parse(word);
		let encrypted = CryptoJS.AES.encrypt(srcs, key, {
			// iv,
			// mode: CryptoJS.mode.CBC,
			mode: CryptoJS.mode.ECB,
			padding: CryptoJS.pad.Pkcs7
		});



		return encrypted.toString();


	},
	// 解密
	aesDecrypt: function(word) {
		var key = CryptoJS.enc.Utf8.parse(keyStr);
		let iv = CryptoJS.enc.Utf8.parse(ivStr);
		var decrypt = CryptoJS.AES.decrypt(word, key, {
			iv,
			mode: CryptoJS.mode.CBC,
			padding: CryptoJS.pkcs7
		});
		return decrypt.toString(CryptoJS.enc.Utf8);
	}
}